<?php
header("Content-type:application/json; charset=utf-8");

$dbhost = 'localhost';  // mysql服务器主机地址
$dbuser = 'root';            // mysql用户名
$dbpass = '';          // mysql用户名密码
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $con )
{
    die('Could not connect: ' . mysqli_error());

}else{

	 mysql_select_db('clickzhan', $con);
	 
	 //INSERT
	 // $sql= "INSERT INTO `number`( `number`) VALUES ('122')";
	 // $result = mysql_query($sql,$con);
	 // if(!$result){
	 // 	die('无法插入数据: ' . mysqli_error($con));
	 // }else{
	 // 	echo('SUCCESS');
	 // }

	 //UPDATE
	  $number=$_REQUEST['number'];
	  // echo $number;
	  $sql = "UPDATE `number` SET `number`=$number WHERE id=2";
	  $result = mysql_query($sql,$con);
	  if(!$result){
	 		die('无法插入数据: ' . mysqli_error($con));
	 	}else{
	 		$resdate = [
	 		'msg' => 'success', 'code' => '0'
	 		];

	 		echo json_encode($resdate);
	 	}

	 //DELECT
	  // $sql = "DELETE FROM `number` WHERE id=4";
	  // $result = mysql_query($sql,$con);
	  // if(!$result){
	 	// 	die('无法插入数据: ' . mysqli_error($con));
	 	// }else{
	 	// 	echo('SUCCESS');
	 	// }

	// echo '数据库连接成功！';

}
mysql_close($con);


?>